extends Node2D


# Called when the node enters the scene tree for the first time.
var date:int=1
var act:String = "静止"
var jltime:float = 0
func _ready() -> void:
	get_child(0).position = get_child(2).position
	for i in range(0,10):
		var rq:Sprite2D = get_child(i)
		rq.texture = $"../日期".sprite_frames.get_frame_texture("日期",i)
		rq.position.x = i*200+200
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	for i in range(0,10):
		var rq:Sprite2D = get_child(i)
		rq.scale.x = (200 - abs(rq.position.x-200))/200
		if abs(rq.position.x-200)>200:
			rq.visible=false
		else:
			rq.visible=true
	pass
	if act =="静止":
		if Input.is_action_just_pressed("右"):
			if date <10:
				act = "向左"
				jltime = 0
			else:
				date = 10
		if Input.is_action_just_pressed("左"):
			
			if date >1:
				act = "向右"
				jltime = 0
			else:
				date = 1
	if jltime ==200:
		if act == "向右":
			date-=1
		if act == "向左":
			date+=1
		act ="静止"
		jltime =0
	else:
		move()
	
func move():
	match act:
		"向左":
			for i in range(0,10):
				var rq:Sprite2D = get_child(i)	
				rq.position.x -= 10
			jltime += 10
		"向右":
			for i in range(0,10):
				var rq:Sprite2D = get_child(i)	
				rq.position.x += 10
			jltime += 10
	pass
